Peripheral devices such as disk drives used in processor-based systems are typically slower than other circuitry in those systems. There have been many attempts to increase the performance of disk drives. However, because disk drives are electromechanical, there may be a finite limit beyond which performance cannot be increased. One way to reduce an information bottleneck at the peripheral device, such as a disk drive, is to use a cache. A cache is a memory device that logically resides between a device, such as a disk drive, and the remainder of the system, and that serves as a temporary storage area for the device. Frequently accessed data resides in the cache after an initial access. Subsequent accesses to the same data may be made to the cache instead of to the cached device.
Generally, two types of disk caches are used, write-through cache and write-back cache. A write-through disk cache means that the information is written both to the cache and to the corresponding disk drive. A write-back disk cache means that information is only written to the cache, and the corresponding disk drive is subsequently updated when the corresponding cache line is flushed. A write-back cache allows write accesses to be kept in the cache, as compared to a write-through cache. Write-back cache performance is typically better than for write-through caches. The possible coherency problems with write-back caching (since the data in the cache may be different than in the corresponding disk drive) are solved by flushing the cache lines to the cached device when needed. A cache line of data is dirty if the data in the cache line has been updated by the system but the corresponding disk drive has not been updated. A clean cache line is a line of data in a cache that has been flushed (updated) to the corresponding disk drive.
Write-back systems frequently flush the data in the cache in response to various power events, during crash or power-fail recovery, or opportunistically during lazy-write periods. Such flush operations can take a long time for large disk caches if there is a lot of dirty data in the cache. This can make shutdowns unbearably long and make a write-back disk-caching solution unacceptable for many customers. Further, in recovering from a crash or power failure in a non-volatile write-back cache, dirty portions must be flushed back to the disk drive. This unfortunately requires reading the entire cache metadata/data, which can be excruciatingly slow for a large cache, even if there is only a very small amount of dirty data in the cache. Thus a need exists for more efficient cache operations.